#include "targetfindinggrid.h"


TargetFindingGrid::TargetFindingGrid()
{
}

TargetFindingGrid::TargetFindingGrid(const vector<vector<int> > & vec)
{
    grid=vec;
}

TargetFindingGrid::TargetFindingGrid(const TargetFindingGrid* t)
{
    grid=t->grid;
    start_x=t->start_x;
    start_y=t->start_y;
    stop_x=t->stop_x;
    stop_y=t->stop_y;

}
TargetFindingGrid::TargetFindingGrid(const TargetFindingGrid& t)
{
    grid=t.grid;
    start_x=t.start_x;
    start_y=t.start_y;
    stop_x=t.stop_x;
    stop_y=t.stop_y;
}


void TargetFindingGrid::set(int val,int x, int y, int z)
{
    switch(z)
    {
    case 0:
        grid[x][y]=val;
        break;
    case 1:
        start_x=x;
        start_y=y;
        break;
    case 2:
        stop_x=x;
        stop_y=y;
        break;
    }

}

int TargetFindingGrid::get(int x, int y, int z)
{
    if(z==0) return grid[x][y];
    return ((start_x==x && start_y==y)||(stop_x==x && stop_y==y))?0:2;
}

int TargetFindingGrid::size(int axis)
{
    if (grid.empty())return 0;
    if(axis==1) return grid.size();
    if(axis==0)return grid[0].size();
    return -1;
}

Grid* TargetFindingGrid::copy()const
{
    return new TargetFindingGrid(this);
}
